package jmlTest;

import java.io.File;

import net.sf.javaml.clustering.Clusterer;
import net.sf.javaml.clustering.KMeans;
import net.sf.javaml.clustering.evaluation.ClusterEvaluation;
import net.sf.javaml.clustering.evaluation.SumOfSquaredErrors;
import net.sf.javaml.core.Dataset;
import net.sf.javaml.core.DenseInstance;
import net.sf.javaml.core.Instance;
import net.sf.javaml.tools.data.FileHandler;
import processing.core.PApplet;


public class JMLTest_001 extends PApplet {
	double[] values = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
	public void setup() {
		Dataset data = null;
		Instance instance = new DenseInstance(values);
		try {
			data = FileHandler.loadDataset(new File("D:\\RESOURCE\\DATABASES\\UCI\\UCI-small\\UCI-small\\iris\\iris.data"), 4, ",");	
		} catch (Exception e) {
			// TODO: handle exception
		}
		Clusterer km=new KMeans(4);
		Dataset[] clusters = km.cluster(data);
		ClusterEvaluation sse= new SumOfSquaredErrors();
		double score=sse.score(clusters);
		System.out.println(score);
	}
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
